package com.burningtower.service.impl;

import com.burningtower.entity.Resource;
import com.burningtower.mapper.ResourceMapper;
import com.burningtower.service.IResourceService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.burningtower.vo.TreeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资源 服务实现类
 * </p>
 *
 * @author zhe
 * @since 2017-11-17
 */
@Service
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements IResourceService {

    @Override
    public TreeVo toVo(Resource resource) {
        TreeVo vo = new TreeVo();
        BeanUtils.copyProperties(resource,vo);
        vo.setIconCls(resource.getIcon());
        vo.setText(resource.getName());
        vo.setState(resource.getOpened()==1?"open":"closed");
        vo.setChecked(false);
        vo.setAttributes(resource.getUrl());
        return vo;
    }
}
